package com.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@Entity
@NamedQueries(
		{
			@NamedQuery(name = "Membership.findMembershipByStatus", query = "select m from Membership m where m.active = :active"),
			@NamedQuery(name = "Membership.findMembershipByName", query = "select m from Membership m where m.name = :name"),
			@NamedQuery(name = "Membership.findMembershipById", query = "select m from Membership m where m.id = :id"),
			@NamedQuery(name = "Membership.search", query = "select m from Membership m where m.name like :name and m.active = :active and m.price >= :priceFrom and m.price <= :priceTo")
		}
	)
public class Membership implements Serializable{
	private static final long serialVersionUID = 1L;
	public static final String FIND_MEMBERSHIP_BY_NAME = "Membership.findMembershipByName";
	public static final String FIND_MEMBERSHIP_BY_ID = "Membership.findMembershipById";
	public static final String FIND_MEMBERSHIP_BY_STATUS = "Membership.findMembershipByStatus";
	public static final String SEARCH = "Membership.search";
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	@Column(unique = true)
	private String name;
	@Column(length = 500)
	private String description;
	private BigDecimal price;
	private int monthValidity;
	private int sessionValidity;
	private Date effectiveFrom;
	private Date effectiveTo;
	private boolean renewable;
	
	private Date createdDate;
	@ManyToOne
	@JoinColumn(name="createdBy")
	private User createdBy;
	
	private Date updatedDate;
	@ManyToOne
	@JoinColumn(name="updatedBy")
	private User updatedBy;
	
	private boolean active;
	
	private int decimalPlaces;  
	public Membership(){
		decimalPlaces = 2; 
		
		price = new BigDecimal(0);
	}

	
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public int getMonthValidity() {
		return monthValidity;
	}

	public void setMonthValidity(int monthValidity) {
		this.monthValidity = monthValidity;
	}

	public int getSessionValidity() {
		return sessionValidity;
	}

	public void setSessionValidity(int sessionValidity) {
		this.sessionValidity = sessionValidity;
	}

	public Date getEffectiveFrom() {
		return effectiveFrom;
	}

	public void setEffectiveFrom(Date effectiveFrom) {
		this.effectiveFrom = effectiveFrom;
	}

	public Date getEffectiveTo() {
		return effectiveTo;
	}

	public void setEffectiveTo(Date effectiveTo) {
		this.effectiveTo = effectiveTo;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createDate) {
		this.createdDate = createDate;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public int getDecimalPlaces() {
		return decimalPlaces;
	}

	public void setDecimalPlaces(int decimalPlaces) {
		this.decimalPlaces = decimalPlaces;
	}

	public boolean isRenewable() {
		return renewable;
	}

	public void setRenewable(boolean renewable) {
		this.renewable = renewable;
	}
	public User getCreatedBy() {
		return createdBy;
	}
	public void setCreatedBy(User createdBy) {
		this.createdBy = createdBy;
	}
	public Date getUpdatedDate() {
		return updatedDate;
	}
	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}
	public User getUpdatedBy() {
		return updatedBy;
	}
	public void setUpdatedBy(User updatedBy) {
		this.updatedBy = updatedBy;
	}





}
